﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text; 
using System.IO;
using System.Web;
using SAASInvest.Contracts;

namespace SAASInvest.WebHost
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "AsynFileUpload" in code, svc and config file together.
    public class AsynFileUpload : IAsynFileUpload
    {
        public FileUploadData AnysUploadFile(FileUploadData uploadData)
        {
            string filePath = Path.Combine(HttpRuntime.AppDomainAppPath, @"Upload\" + uploadData.FileName);
            using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write))
            {
                if (uploadData.Offset < uploadData.Length)
                {
                    fs.Seek(uploadData.Offset, SeekOrigin.Begin);
                    fs.Write(uploadData.UploadData, 0, (int)uploadData.DataCount);
                    uploadData.Offset = fs.Length;
                    uploadData.UploadData = null;
                    uploadData.DataCount = 0;
                }
                fs.Close();
            }
            return uploadData;
        }


        public List<FileUploadData> GetFileDatasList()
        {
            return new List<FileUploadData>();
        }

        public FileUploadData GetFile(string fileFullName)
        {
            return new FileUploadData();
        }
    }
}
